﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Runtime.CompilerServices;
using System.Runtime.InteropServices;
using System.Text;
using System.Threading.Tasks;

namespace Lesson4_练习题
{
    internal class Program
    {
        class Person
        {
            public string name;
            public int age;
            public float height;
            public string stress;
            public int capacity;
            public Person(string name,int age, float height, string stress) : this( name, age)    //优先调用name和age函数
            {

                this.height = height;
                this.stress = stress;
            }
            //重载有参函数
            public Person(string name, int  age)
            {
                this.name = name;
                this.age = age;
            }
         

        }
        class Class
        {
           public string name;
           public int capacity;
           public Student[] students;
            public Class(string name, int capacity, Student[] students)
            {
                    this.name = name;
                    this.capacity = capacity;
                this.students = students;
            }
        }
        class Student
        {

        }
        class Ticket   
        {
            public uint distance;   // 传入公里和加个两个变量
            public float price; 
            
            public Ticket(uint diadance)
            {
                this.distance = diadance;
                price = GetPrice();
            }
            private float GetPrice()
            {
                if(distance  >300)   //大于300公里9折
                {
                    return distance * 0.7f;   
                }
                else if (distance >201&&  distance<300)
                {
                    return distance *0.8f;
                }
                else if(distance >101&&distance <200)
                {
                    return distance *0.9f;
                }
                else
                {
                    return distance;
                }
            }
            public void ShowInfo()
            {
                Console.WriteLine("{0}公里{1}元",distance,price);
            }
            //对传入的距离进行输入
        }

        static void Main(string[] args)
        {
            //声明若干对象
            Person p1 = new Person("张三",18,187.2f," 刘楠");   //使用有参函数构造是，无参函数自动被顶掉
            Person p2 = new Person("王五", 17);
            Student s1 = new Student();
            Student s2 = new Student();
            Class c1 = new Class("Unity", 999999, new Student[]{ s1,s2 });
            Ticket f = new Ticket(304);
            f.ShowInfo();

        }

    }
}
